808A - Lucky Year - CodeForces Solution


implementation *900

Please click on ads to support us..

Python Code:

n=int(input())
if n>=0 and n<=9:
    print(1)
else:
    s=str(n)
    k=(int(s[0])+1)*(10**(len(s)-1))
    print(k-n)

C++ Code:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll int d=0;
    string s; cin>>s;

    if(s.length()==1) cout<<1<<endl;
    else{
        int l=s.length(); d=s[0]-'0';
        for(int i=1; i<l; i++){
            d= (d*10) + (s[i]-'0');
        }
        // cout<<d+100-d<<endl;
        int a=s[0]-'0'+1;
        a=a*pow(10, l-1);
        cout<<a-d<<endl;
    }

    return 0;
}


Comments

Submit
0 Comments
More Questions

1326B - Maximums
1635C - Differential Sorting
961A - Tetris
1635B - Avoid Local Maximums
20A - BerOS file system
1637A - Sorting Parts
509A - Maximum in Table
1647C - Madoka and Childish Pranks
689B - Mike and Shortcuts
379B - New Year Present
1498A - GCD Sum
1277C - As Simple as One and Two
1301A - Three Strings
460A - Vasya and Socks
1624C - Division by Two and Permutation
1288A - Deadline
1617A - Forbidden Subsequence
914A - Perfect Squares
873D - Merge Sort
1251A - Broken Keyboard
463B - Caisa and Pylons
584A - Olesya and Rodion
799A - Carrot Cakes
1569B - Chess Tournament
1047B - Cover Points
1381B - Unmerge
1256A - Payment Without Change
908B - New Year and Buggy Bot
979A - Pizza Pizza Pizza
731A - Night at the Museum